#!/bin/bash

org_hosts=/etc/hosts
bak_hosts=$org_hosts"-"`date +"%Y-%m-%d"`


tmp_hosts=/tmp/hosts
tmp_html=/tmp/html
tmp_ctx=/tmp/ctx


url=http://www.cnblogs.com/tintin1926/archive/2012/07/15/2592659.html

wget $url -O $tmp_html > /dev/null 2>&1

if [ $? -ne 0 -o ! -f $org_hosts -o ! -f $tmp_html ];then
	exit 1
fi


sed -n '/#youtube/,/v24.lscache8.c.youtube.com/p' $tmp_html  > $tmp_ctx

sed -i s'/.*#/#/' $tmp_ctx
echo "#youtube_end" >> $tmp_ctx


#cp -f $org_hosts $bak_hosts
#cp -f $org_hosts $tmp_hosts
#
#
#sed -i '/#youtube/,/#youtube_end/d' $tmp_hosts
#
#cat $tmp_ctx >> $tmp_hosts
#
#cp -f $tmp_hosts $org_hosts
#
#rm -f $tmp_hosts $tmp_html $tmp_ctx




